package client.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;

import client.network.MessageMailBox;

public class InfoBar extends JPanel implements ActionListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 681818618312276427L;
	private JTextField message;
	MessageMailBox messageMailBox;
	

	public InfoBar(int width, int height, Canvas canvas, JButton clear, MessageMailBox messageMailBox) {
		message = new JTextField();
		setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		this.messageMailBox = messageMailBox;
		
		message.setEditable(false);

		clear.addActionListener(this);

		c.gridy = 0;
		message.setSelectedTextColor(Color.black);
		add(message, c);

		message.setPreferredSize(new Dimension(width - 124, height));
		c.gridx = 1;
		add(clear, c);

	}

	public void setMessage(String text) {
		message.setText(text);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		messageMailBox.addOutgoingMessage("CLEAR");
	}

}
